home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 101-125 / disk_108 / tek / vt100.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  20KB  |  808 lines

  1. /********************************************************************
  2.  *  vt100 terminal emulator with xmodem transfer capability
  3.  *
  4.  *    v2.65        NG  - added tek4014 emulation
  5.  *    v2.6 870227 DBW - bug fixes for all the stuff in v2.5
  6.  *    v2.5 870214 DBW - more additions (see readme file)
  7.  *    v2.4 861214 DBW - lots of fixes/additions (see readme file)
  8.  *    v2.3 861101 DBW - minor bug fixes
  9.  *    v2.2 861012 DBW - more of the same
  10.  *    v2.1 860915 DBW - new features (see README)
  11.  *         860901 ACS - Added Parity and Word Length and support code
  12.  *         860823 DBW - Integrated and rewrote lots of code
  13.  *    v2.0 860809 DBW - Major rewrite
  14.  *    v1.1 860720 DBW    - Switches, 80 cols, colors, bug fixes
  15.  *    v1.0 860712 DBW    - First version released
  16.  *
  17.  *  use <esc> to abort xmodem or kermit transfers
  18.  *
  19.  *  written by Michael Mounier
  20.  *  new version by Dave Wecker
  21.  *******************************************************************/
  22.  
  23. /*  all includes defines and globals */
  24. #include "vt100.h"
  25.  
  26. /**************************************************************/
  27. /* here are all the global definitions that appear in vt100.h */
  28. /**************************************************************/
  29.  
  30. char    bufr[BufSize];
  31. int     fd, timeout = FALSE, ttime;
  32. int    multi = FALSE, server;
  33. long    bytes_xferred;
  34. char    MyDir[60];
  35. struct    FileLock *MyDirLock = NULL;
  36. struct    FileLock *StartLock = NULL;
  37. struct    IntuitionBase *IntuitionBase;
  38. struct    GfxBase *GfxBase;
  39.  
  40. struct    TextAttr myattr = {
  41.     (STRPTR) "topaz.font",
  42.     8,
  43.     0,
  44.     0};
  45. struct    TextFont *myfont = NULL;
  46. struct NewScreen NewScreen = {
  47.    0L,0L,640L,200L,1L,       /* left, top, width, height, depth */
  48.    0,1,HIRES,    /* DetailPen, BlockPen, ViewModes */
  49.    CUSTOMSCREEN,&myattr,   /* Type, Font */
  50.    (UBYTE *)"VT100", /* Title */
  51.    NULL,NULL };         /* Gadgets, Bitmap */
  52. struct NewWindow NewWindow = {
  53.    0,0L,640L,200L,     /* left, top, width, height */
  54.    0,1,              /* detailpen, blockpen */
  55.    MENUPICK|CLOSEWINDOW|RAWKEY|REQCLEAR|REQSET|ACTIVEWINDOW|INACTIVEWINDOW,
  56.    SMART_REFRESH|ACTIVATE|BORDERLESS|WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG,
  57.    NULL,NULL,        /* FirstGadget, CheckMark */
  58.    (UBYTE *)NULL,
  59.    NULL,             /* set screen after open screen */
  60.    NULL,             /* bitmap */
  61.    640L, 200L, 640L, 200L,/* minw, minh, maxw, maxh */
  62.    CUSTOMSCREEN      /* Type */
  63.    };
  64. struct IntuiText MyTitle = {
  65.     0,1,JAM2,26,0,    /* front pen, back pen, mode, left, top */
  66.     &myattr,        /* font */
  67.     (UBYTE *)VERSION,    /* title */
  68.     NULL};        /* next text */
  69. struct Screen *myscreen = NULL;      /* ptr to applications screen */
  70. struct Window *mywindow = NULL;     /* ptr to applications window */
  71. struct ViewPort *myviewport;
  72. struct RastPort *myrastport;
  73. struct IntuiMessage *NewMessage;    /* msg structure for GetMsg() */
  74. struct Preferences  *Prefs;        /* preferences from GetPrefs() */
  75.  
  76. /**** String requester support ******/
  77.  
  78. char    InpBuf[80],UndoBuf[80],Prompt[80];
  79. struct IntuiText donetxt = {
  80.     1,0,JAM2,0,0,    /* front pen, back pen, mode, left, top */
  81.     &myattr,        /* font */
  82.     (UBYTE *)"DONE",    /* question to ask */
  83.     NULL};        /* next text */
  84. struct Gadget mydonegad = {
  85.     NULL,290,2,40,10,/* next,left,top,width,height */
  86.     GADGHCOMP|REQGADGET,/* flags */
  87.     RELVERIFY|ENDGADGET,/* activation */
  88.     BOOLGADGET,        /* gadget type */
  89.     NULL,NULL,&donetxt,    /* gad render, sel render, gad text */
  90.     0L,NULL,2,NULL};    /* mutual exclude, special, ID, user data */
  91. struct    StringInfo mystrinfo = {
  92.     (UBYTE *)InpBuf,
  93.     (UBYTE *)UndoBuf,
  94.     0,80,0,0,0,0,    /* initial, max, disp, undo, #chrs, dsp chrs */
  95.     0,0,NULL,0L,NULL};    /* left,top,layer,longint,keymap */
  96. struct Gadget mystrgad = {
  97.     &mydonegad,10,12,320,10,    /* next,left,top,width,height */
  98.     GADGHCOMP|REQGADGET,/* flags */
  99.     ENDGADGET,STRGADGET,/* activation, type */
  100.     NULL,NULL,NULL,    /* gad render, sel render, gad text */
  101.     0L,            /* mutual exclude */
  102.     (APTR)&mystrinfo,    /* special info */
  103.     1,NULL};        /* gadget ID, user data */
  104. struct IntuiText mystrtxt = {
  105.     0,1,JAM2,10,2,    /* front pen, back pen, mode, left, top */
  106.     &myattr,        /* font */
  107.     (UBYTE *)Prompt,    /* question to ask */
  108.     NULL};        /* next text */
  109. struct Requester myrequest = {
  110.     NULL,200,40,340,22,    /* older requester, left, top, width, height */
  111.     0,0,&mystrgad,    /* relleft reltop, gadgets */
  112.     NULL,        /* border */
  113.     &mystrtxt,        /* text */
  114.     NULL,1,NULL,    /* flags, back fill pen, layer */
  115.     {0,0,0,0,0,0,0,0,
  116.      0,0,0,0,0,0,0,0,
  117.      0,0,0,0,0,0,0,0,
  118.      0,0,0,0,0,0,0,0},    /* pad1 */
  119.     NULL,NULL,        /* image bit map, rquest window */
  120.     {0,0,0,0,0,0,0,0,0,
  121.      0,0,0,0,0,0,0,0,0,
  122.      0,0,0,0,0,0,0,0,0,
  123.      0,0,0,0,0,0,0,0,0} /* pad2 */
  124.     };
  125. int numreqs = 0;    /* number of outstanding requestors */
  126.  
  127. /***** menu structures *****/
  128. struct MenuItem FileItem[FILEMAX];
  129. struct IntuiText FileText[FILEMAX];
  130. struct MenuItem CommItem[COMMAX];
  131. struct IntuiText CommText[COMMAX];
  132. struct MenuItem RSItem[RSMAX];
  133. struct IntuiText RSText[RSMAX];
  134. struct MenuItem ParItem[PARMAX];
  135. struct IntuiText ParText[PARMAX];
  136. struct MenuItem XFItem[XFMAX];
  137. struct IntuiText XFText[XFMAX];
  138. struct MenuItem ScriptItem[SCRIPTMAX];
  139. struct IntuiText ScriptText[SCRIPTMAX];
  140. struct MenuItem UtilItem[UTILMAX];
  141. struct IntuiText UtilText[UTILMAX];
  142. struct Menu menu[MAXMENU];
  143. struct IOExtSer *Read_Request;
  144. char *rs_in;
  145. struct IOExtSer *Write_Request;
  146. char rs_out[2];
  147. struct timerequest Timer;
  148. struct MsgPort *Timer_Port = NULL;
  149. struct timerequest Script_Timer;
  150. struct MsgPort *Script_Timer_Port = NULL;
  151. struct IOAudio Audio_Request;
  152. struct MsgPort *Audio_Port = NULL;
  153. UBYTE  *BeepWave;
  154. UBYTE  Audio_AllocMap[4] = { 1, 8, 2, 4 };
  155. int x,y,curmode;
  156. int MINX    = 0;
  157. int MAXX    = 632;
  158. int MINY    = 14;
  159. int MAXY    = 198;
  160. int top        = 14;
  161. int bot        = 198;
  162. int savx    = 0;
  163. int savy    = 14;
  164. int savmode    = 0;
  165. int nlmode    = 0;
  166. int alt        = 0;
  167. int savalt    = 0;
  168. int a[2]    = { 0, 0 };
  169. int sa[2]    = { 0, 0 };
  170. int  inesc    = -1;
  171. int  inctrl    = -1;
  172. int  private    = 0;
  173. int  badseq    = 0;
  174. int  maxcol    = 79;
  175.  
  176. /*************************** defaults *******************************/
  177. int    p_baud         = 2400;        /* baud rate */
  178. int    p_screen     = 1;        /* 0 = WORKBENCH,        1 = CUSTOM */
  179. int    p_wbcolors   = 1;        /* 0 = Custom, 1 = Workbench colors */
  180. int    p_interlace  = 1;        /* 0 = no interlace,    1 = interlace */
  181. int    p_depth         = 1;        /* number of bit planes (1 or 2) */
  182. int    p_foreground = 0x950;        /* default foreground RGB color */
  183. int    p_background = 0x000;        /* default background RGB color */
  184. int    p_bold         = 0x900;        /* default BOLD       RGB color */
  185. int    p_cursor     = 0x009;        /* default Cursor      RGB color */
  186. int    p_lines         = 48;        /* number of lines on the screen */
  187. int    p_mode         = 1;        /* 0 = image, 1 = CRLF (for kermit) */
  188. int    p_buffer     = 512;        /* read buffer size (>= 512 bytes) */
  189. int     p_parity     = 0;        /* 0=none,1=mark,2=space,3=even,4=odd */
  190. long    p_break         = 750000;        /* break time (in micro seconds) */
  191. int    p_volume     = 64;        /* beep volume (0 = DisplayBeep) */
  192. int    p_wrap         = 0;        /* 0 = truncate, 1 = wrap long lines */
  193. int    p_keyapp     = 0;        /* 0 = numeric, 1 = application keypad */
  194. int    p_curapp     = 0;        /* 0 = cursor, 1 = application cursor */
  195. int    p_echo         = 0;        /* 0 = full duplex, 1 = half duplex */
  196. int    p_bs_del     = 0;        /* 0 = normal, 1 = swap bs and delete */
  197. int    p_convert    = 1;        /* 1 = convert filenames to lower case */
  198. char    p_keyscript  = 0x7E;        /* function key script introducer = ~ */
  199. char    *p_f[10]     = {        /* function key defaults */
  200.     "\033OP","\033OQ","\033OR","\033OS",
  201.     "f5","f6","f7","f8","f9","f10" };
  202.  
  203. char    *p_F[10]     = {        /* shifted function key defaults */
  204.     "F1","F2","F3","F4","F5",
  205.     "F6","F7","F8","F9","F10"};
  206.  
  207. /* for script file */
  208. int script_on;
  209. int script_wait;
  210. int doing_init = 0;
  211.  
  212. /******************************************************/
  213. /*                   Main Program                     */
  214. /*                                                    */
  215. /*      This is the main body of the program.         */
  216. /******************************************************/
  217.  
  218. char lookahead[80];
  219. FILE *tranr = NULL;
  220. FILE *trans = NULL;
  221. int capture,send;
  222. char name[80];
  223. struct MsgPort *mySerPort;
  224. int KeepGoing;    /* moved here to be global for tek emulation */
  225.  
  226. main(argc,argv)
  227. int    argc;
  228. char    **argv;
  229.     {
  230.     ULONG class;
  231.     unsigned int code, qual;
  232.     int i,la,dola,actual;
  233.     char c,*ptr;
  234.  
  235.     ptr = InitDefaults(argc,argv);
  236.     InitDevs();
  237.     InitFileItems();
  238.     InitCommItems();
  239.     InitScriptItems();
  240.     InitUtilItems();
  241.     InitTekItems();        /* added for tek emulation     */
  242.     InitMenu();
  243.     InitTekMenu();        /* added for tek emulation     */
  244.     SetMenuStrip(mywindow,&menu[0]);
  245.     PrintIText(mywindow->RPort,&MyTitle,0L,0L);
  246.     InitTekDev();    /* added for tek emulation     */
  247.  
  248.     MyDir[0]  =        '\000';
  249.     StartLock =    (struct FileLock *)((ULONG)((struct Process *)
  250.             (FindTask(NULL)))->pr_CurrentDir);
  251.     MyDirLock = (struct FileLock *)DupLock(StartLock);
  252.     KeepGoing =        TRUE;
  253.     capture   =        FALSE;
  254.     send      =        FALSE;
  255.     maxcol    =        MAXX / 8;
  256.     la          =        0;
  257.     x          =        MINX ; 
  258.     y          =        MINY; 
  259.     curmode   =        FS_NORMAL;
  260.     script_on =     FALSE;
  261.     script_wait=    TRUE;
  262.     SetAPen(mywindow->RPort,1L);
  263.     cursorflip();
  264.     cursorflip();    
  265.     emit(12);
  266.     mySerPort = Read_Request->IOSer.io_Message.mn_ReplyPort;
  267.     SendIO(Read_Request);
  268.  
  269.     /* see if we had a startup script */
  270.     if (ptr != NULL) script_start(ptr);
  271.  
  272.     while( KeepGoing )
  273.         {
  274.         /* wait for window message or serial port message */
  275.         cursorflip();
  276.         if (script_wait)    /* if script ready dont wait here */
  277.         Wait(
  278.          (1L << mySerPort->mp_SigBit) |
  279.          (1L << mywindow->UserPort->mp_SigBit) |
  280.          (1L << Script_Timer_Port->mp_SigBit));
  281.         cursorflip();
  282.         
  283.         /* do ascii file send */
  284.         if (send)
  285.         {
  286.         if ((c=getc(trans)) != EOF) {
  287.             if (c == '\n') c = '\r';
  288.             sendchar(c);
  289.             }
  290.         else {
  291.             fclose(trans);
  292.             req("File Sent","",0);
  293.             send=FALSE;
  294.             }
  295.         }
  296.  
  297.         /* see if there are any characters from the host */
  298.         if (CheckIO(Read_Request)) {
  299.         WaitIO(Read_Request);
  300.         c = rs_in[0] & 0x7F;
  301.         doremote(c);
  302.         if (script_on) chk_script(c);
  303.             if (capture && c != 10) {
  304.                   if (c == 13) c = 10;
  305.             putc(c , tranr);
  306.             }
  307.         Read_Request->IOSer.io_Command = SDCMD_QUERY;
  308.         DoIO(Read_Request);
  309.         Read_Request->IOSer.io_Command = CMD_READ;
  310.         actual = (int)Read_Request->IOSer.io_Actual;
  311.         if (actual > 0) {
  312.             if (inesc   <  0 &&
  313.             inctrl  <  0 &&
  314.             a[alt]  == 0 &&
  315.             capture == FALSE) dola = 1;
  316.             else dola = 0;
  317.             Read_Request->IOSer.io_Length =
  318.             Read_Request->IOSer.io_Actual;
  319.             DoIO(Read_Request);
  320.             Read_Request->IOSer.io_Length = 1;
  321.  
  322.             for (i = 0; i < actual; i++) {
  323.             c=rs_in[i] & 0x7f;
  324.             if (script_on) chk_script(c);
  325.  
  326.             if (dola == 1) {
  327.                 if (c >= ' ' && c <= '~' && la < 80)
  328.                 lookahead[la++] = c;
  329.                 else {
  330.                 if (la > 0) {
  331.                     emitbatch(la,lookahead);
  332.                     la = 0;
  333.                     }
  334.                 doremote(c);
  335.                 dola = 0;
  336.                 }
  337.                 }
  338.             else {
  339.                 doremote(c);
  340.                 if (inesc   <  0 &&
  341.                 inctrl  <  0 &&
  342.                 a[alt]  == 0 &&
  343.                 capture == FALSE) dola = 1;
  344.                 if (capture && c != 10) {
  345.                 if (c == 13) c = 10;
  346.                 putc(c , tranr);
  347.                 }
  348.                 }
  349.             }
  350.  
  351.             /* dump anything left in the lookahead buffer */
  352.             if (la > 0) {
  353.             emitbatch(la,lookahead);
  354.             la = 0;
  355.             }
  356.             }
  357.         SendIO(Read_Request);
  358.         }
  359.  
  360.         while((NewMessage = 
  361.             (struct IntuiMessage *)GetMsg(mywindow->UserPort))
  362.             != FALSE) {
  363.         class = NewMessage->Class;
  364.         code = NewMessage->Code;
  365.         qual = NewMessage->Qualifier;
  366.         ReplyMsg( NewMessage );
  367.         switch( class )
  368.             {
  369.             case REQCLEAR:
  370.             numreqs = 0;
  371.             break;
  372.  
  373.             case CLOSEWINDOW:
  374.             KeepGoing = FALSE;
  375.             break;
  376.  
  377.             case RAWKEY:
  378.             c = toasc(code,qual,0);
  379.             if (p_echo) doremote(c);
  380.             break;
  381.  
  382.             case NEWSIZE:
  383.             emit(12);
  384.             break;
  385.  
  386.             case MENUPICK:
  387.             handle_menupick(class,code);
  388.             break;                    
  389.  
  390.             default:
  391.             PrintIText(mywindow->RPort,&MyTitle,0L,0L);
  392.             break;
  393.             }   /* end of switch (class) */
  394.         }   /* end of while ( newmessage )*/
  395.  
  396.             if (!script_wait || 
  397.                  (CheckIO(&Script_Timer) && 
  398.             script_wait == WAIT_TIMER))
  399.         do_script_cmd(NEXTCOMMAND);
  400.         }  /* end while ( keepgoing ) */
  401.         
  402.     /*   It must be time to quit, so we have to clean
  403.     *   up and exit.
  404.     */
  405.  
  406.     cleanup("",0);
  407.  
  408.     } /* end of main */
  409.  
  410. /* cleanup code */
  411.  
  412. cleanup(reason, fault)
  413. char *reason;
  414. int fault;
  415.     {
  416.     switch(fault) {
  417.     case 0:        /* quitting close everything */
  418.     ClearMenuStrip( mywindow ); 
  419.     CloseDevice(&Audio_Request);
  420.     if (MyDirLock != NULL) UnLock(MyDirLock);
  421.  
  422.     case 8:        /* error opening audio */
  423.     DeletePort(Audio_Port);
  424.     FreeMem(BeepWave,BEEPSIZE);
  425.     CloseDevice(&Timer);
  426.  
  427.     case 7:        /* error opening timer */
  428.     DeletePort(Timer_Port);  
  429.     CloseDevice(&Script_Timer);
  430.     DeletePort(Script_Timer_Port);
  431.  
  432.     case 6:        /* error opening write device */
  433.     DeletePort(Write_Request->IOSer.io_Message.mn_ReplyPort);
  434.     FreeMem(Write_Request,(long)sizeof(*Write_Request));
  435.     CloseDevice(Read_Request);
  436.  
  437.     case 5:        /* error opening read device */
  438.     DeletePort(Read_Request->IOSer.io_Message.mn_ReplyPort);
  439.     FreeMem(Read_Request,(long)sizeof(*Read_Request));
  440.  
  441.     case 4:        /* error opening window */
  442.     if (myfont   != NULL) CloseFont( myfont );
  443.     if (mywindow != NULL) CloseWindow( mywindow );
  444.     if (p_screen != 0) CloseScreen( myscreen );
  445.  
  446.     case 3:        /* error opening screen */
  447.     case 2:        /* error opening graphics library */
  448.     case 1:        /* error opening intuition */
  449.     default:
  450.     if (*reason) puts (reason);
  451.     }
  452.     CloseTek();        /* added for tek emulation    */
  453.     exit(fault);
  454.     } 
  455.  
  456. do_capture(file)
  457. char *file;
  458.     {
  459.     if (capture == TRUE)
  460.         {
  461.         capture=FALSE;
  462.         fclose(tranr);
  463.         req("End File Capture","",0);
  464.         }
  465.     else
  466.         {
  467.         if (file == NULL) {
  468.         name[0] = '\000';
  469.             req("Ascii Capture:",name,1);
  470.         } 
  471.     else strcpy(name, file);
  472.         if ((tranr=fopen(name,"w")) == 0) {
  473.         capture=FALSE;
  474.         req("Error Opening File","",0);
  475.         return(FALSE);
  476.         }
  477.     capture=TRUE;
  478.         }
  479.     }
  480.  
  481. do_send(file)
  482. char *file;
  483.     {
  484.     if (send == TRUE)
  485.     { 
  486.         send=FALSE;
  487.         fclose(trans);
  488.         req("File Send Cancelled","",0);
  489.         }
  490.     else
  491.         {
  492.         if (file == NULL) {
  493.         name[0] = '\000';
  494.             req("Ascii Send:",name,1);
  495.             }
  496.     else strcpy(name, file);
  497.         if ((trans=fopen(name,"r")) == 0) {
  498.            send=FALSE;
  499.         req("Error Opening File","",0);
  500.         return(FALSE);
  501.         }
  502.     send=TRUE;
  503.     }
  504.     }
  505.  
  506. void setparams()
  507.     {
  508.     Read_Request->IOSer.io_Command = 
  509.     Write_Request->IOSer.io_Command = 
  510.         SDCMD_SETPARAMS;
  511.     DoIO(Read_Request); DoIO(Write_Request);
  512.     Read_Request->IOSer.io_Command = CMD_READ;
  513.     SendIO(Read_Request);
  514.     Write_Request->IOSer.io_Command = CMD_WRITE;
  515.     }
  516.  
  517. void hangup ()
  518.     {
  519.     AbortIO(Read_Request);
  520.     CloseDevice (Read_Request);
  521.     Timer.tr_time.tv_secs=0L;
  522.     Timer.tr_time.tv_micro=750000L;
  523.     DoIO((char *) &Timer.tr_node);
  524.     OpenDevice (SERIALNAME,NULL,Read_Request,NULL);
  525.     setparams();
  526.     }
  527.  
  528. void redocomm() {
  529.     ClearMenuStrip( mywindow );         /* Remove old menu */
  530.     InitCommItems();                    /* Re-do comm menu   */
  531.     SetMenuStrip(mywindow,&menu[0]);    /* Re-display the menu */    
  532.     }
  533.  
  534. void setserbaud(baud, redomenu)
  535. int baud;
  536. LONG redomenu;
  537.     {
  538.     AbortIO(Read_Request);
  539.     Write_Request->io_Baud = Read_Request->io_Baud = baud;
  540.     setparams();
  541.     p_baud = baud;
  542.     if (redomenu) redocomm();
  543.     }
  544.  
  545. void redoutil() {
  546.     ClearMenuStrip(mywindow);
  547.     InitUtilItems();
  548.     SetMenuStrip(mywindow,&menu[0]);
  549.     }
  550.  
  551. void 
  552. handle_menupick(class, code)
  553. ULONG class;
  554. unsigned int code;
  555.     {
  556.     unsigned int menunum, itemnum, subnum;
  557.  
  558.     if (code == MENUNULL) return;
  559.  
  560.     menunum = MENUNUM( code );
  561.     itemnum = ITEMNUM( code );
  562.     subnum  = SUBNUM( code );
  563.     switch( menunum ) {
  564.     case 0:
  565.     switch( itemnum ) {
  566.         case 0:
  567.         do_capture(NULL);
  568.         break;
  569.  
  570.         case 1:
  571.         do_send(NULL);
  572.         break;
  573.  
  574.         case 2:
  575.         if (p_parity > 0) {
  576.         req("Parity setting prevents this","",0);
  577.         break;
  578.         }
  579.         name[0] = '\000';
  580.         req("Xmodem Receive:",name,1);
  581.         multi_xfer(name,XMODEM_Read_File,0);
  582.         break;
  583.  
  584.         case 3:
  585.         if (p_parity > 0) {
  586.         req("Parity setting prevents this","",0);
  587.         break;
  588.         }
  589.         name[0] = '\000';
  590.         req("Xmodem Send:",name,1);
  591.         multi_xfer(name,XMODEM_Send_File,1);
  592.         break;
  593.  
  594.         case 4:
  595.         server = TRUE;
  596.         name[0] = '\000';
  597.         req("Kermit GET remote file(s):",name,1);
  598.         multi_xfer(name,dokreceive,0);
  599.             break;
  600.  
  601.         case 5:
  602.         multi_xfer("",dokreceive,0);
  603.         break;
  604.  
  605.         case 6:
  606.         server = TRUE;
  607.         name[0] = '\000';
  608.         req("Kermit Send local name:",name,1);
  609.         multi_xfer(name,doksend,1);
  610.         break;
  611.  
  612.         case 7:
  613.         saybye();
  614.         break;
  615.         }
  616.     break;
  617.  
  618.     case 1:
  619.     switch( itemnum ) {
  620.         case 0:
  621.         switch( subnum ) {
  622.         case 0:
  623.         setserbaud(300, FALSE);
  624.         break;
  625.  
  626.         case 1:
  627.         setserbaud(1200, FALSE);
  628.         break;
  629.  
  630.         case 2:
  631.         setserbaud(2400, FALSE);
  632.         break;
  633.  
  634.         case 3:
  635.         setserbaud(4800, FALSE);
  636.         break;
  637.  
  638.         case 4:
  639.         setserbaud(9600, FALSE);
  640.         break;
  641.         }
  642.         break;        
  643.  
  644.         case 1:
  645.         /* Set  Parity */
  646.         p_parity = subnum;
  647.         break;
  648.  
  649.         case 2:
  650.         /* set transfer mode */
  651.         if (subnum < 2) p_mode = subnum;
  652.         else {
  653.         if (p_convert)    p_convert = 0;
  654.         else        p_convert = 1;
  655.         redocomm();
  656.         }
  657.         break;
  658.         }
  659.     break;
  660.  
  661.     case 2:
  662.     if (!itemnum && !script_on) {
  663.         name[0] = '\000';
  664.         req("Script file name:",name,1);
  665.         script_start(name);
  666.         }
  667.     if (itemnum && script_on) exit_script();
  668.     break;
  669.  
  670.     case 3:
  671.     switch( itemnum ) {
  672.         case 0:
  673.         sendbreak();
  674.         break;
  675.  
  676.         case 1:
  677.         hangup();
  678.         break;
  679.  
  680.         case 2:
  681.         strcpy(name,MyDir);
  682.         req("Directory:",name,1);
  683.         set_dir(name);
  684.         break;
  685.  
  686.         case 3:
  687.         top = MINY; bot = MAXY; savx = MINX; savy = MINY;
  688.         curmode = FS_NORMAL; inesc = -1;
  689.         a[0] = 0; a[1] = 0; sa[0] = 0; sa[1] = 0;
  690.         redoutil();
  691.         emit(12);
  692.         break;
  693.  
  694.         case 4:
  695.         if (p_echo) p_echo = 0;
  696.         else    p_echo = 1;
  697.         redoutil();
  698.         break;
  699.  
  700.         case 5:
  701.         if (p_wrap) p_wrap = 0;
  702.         else        p_wrap = 1;
  703.         redoutil();
  704.         break;
  705.  
  706.         case 6:
  707.         if (p_keyapp) p_keyapp = 0;
  708.         else          p_keyapp = 1;
  709.         redoutil();
  710.         break;
  711.  
  712.         case 7:
  713.         if (p_curapp) p_curapp = 0;
  714.         else          p_curapp = 1;
  715.         redoutil();
  716.         break;        
  717.  
  718.         case 8:
  719.         swap_bs_del();
  720.         redoutil();
  721.         break;
  722.         }
  723.     case 4:            /* new menu items added for tek emulation     */
  724.     switch(itemnum) {
  725.         case 0:                /* choose tek scale        */
  726.             switch (subnum) {
  727.                 case 0:
  728.                     t_scale = 0;    /* choose 1020x780 resolution    */
  729.                     break;
  730.                 case 1:
  731.                     t_scale = 1;    /* choose 640x400    */
  732.                     break;
  733.             }
  734.         break;
  735.         case 1:                /* choose screen depth    */
  736.             switch (subnum) {
  737.                 case 0:
  738.                     t_cmd_depth("1");
  739.                     break;
  740.                 case 1:
  741.                     t_cmd_depth("2");
  742.                     break;
  743.                 case 2:
  744.                     t_cmd_depth("3");
  745.                     break;
  746.                 case 3:
  747.                     t_cmd_depth("4");
  748.                     break;
  749.             }
  750.         break;
  751.         case 2:                /*    choose interlace     */
  752.             switch (subnum) {
  753.                 case 0:
  754.                     t_cmd_interlace("0");
  755.                     break;
  756.                 case 1:
  757.                     t_cmd_interlace("1");
  758.                     break;
  759.             }
  760.         break;
  761.     }
  762.     break;
  763.  
  764.     case 5:
  765.         switch (itemnum) {
  766.             case 0:            /* tek screen on/off    */
  767.                 switch(subnum) {
  768.  
  769. /*    emits("select screen on/off\n");
  770.     printf("select screen on/off\n");    */
  771.  
  772.                     case 0:            /* tek screen off  */
  773.                     t_cmd_on("0");
  774.                     break;
  775.                     case 1:            /* tek screen on   */
  776.                     t_cmd_on("1");
  777.                     break;
  778.                 }
  779.                 break;
  780.             case 1:
  781.                 doremote(29);
  782.                 doremote(31);    /* force tek screen to front    */
  783.             break;
  784.             case 2:
  785.                 doremote(24);    /* force vt screen to front */
  786.             break;
  787.             case 3:        /* clear both screens    */
  788. /*                doremote(24);    */
  789.                 if(Tek_screen_open == 1) {
  790.                     doremote(29);
  791.                     doremote(27);    
  792.                     doremote(12);
  793.                     doremote(24);
  794.                 }
  795. /*                doremote(27);
  796.                 doremote('c');    */
  797.                 inesc = -1;
  798.                 emit(12);
  799.             break;
  800.             case 4:                    /* quit    */
  801.                 KeepGoing = FALSE;
  802.             break;
  803.         }
  804.     break;
  805.     } /* end of switch ( menunum ) */
  806.     }
  807.  
  808.